package leetcode.二叉树;

public class 平衡二叉树110 {
    public static int maxDepth(TreeNode root) {
        if(root == null)
            return 0;
        return 1 + Math.max(maxDepth(root.left),maxDepth(root.right));

    }
    public boolean isBalanced(TreeNode root) {
        if(root == null)
            return true;
        if(Math.abs(maxDepth(root.left) - maxDepth(root.right)) > 1)
            return false;
        return isBalanced(root.left) && isBalanced(root.right);

    }
}
